package demo2;

public class Test {
    public static void insertSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            int j = i - 1;
            int tmp = arr[i];
            while(j >= 0) {
                if(arr[j] > tmp) {
                    arr[j+1] = arr[j];
                    j--;
                } else {
                    arr[j+1] = tmp;
                    break;
                }
            }
            if(j < 0) {
                arr[j+1] = tmp;
            }
        }
    }

    public static void main(String[] args) {

    }
}
